package sisicotren.ui.windows;

import javax.swing.table.AbstractTableModel;


public class ReadOnlyAbstractTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 1L;
	
	public ReadOnlyAbstractTableModel(String [] cols, Object [][] data) {
		this.cols = cols;
		this.data = data;
	}

	public String getColumnName(int col) {
		return cols[col];
	}
	
	@Override
	public int getRowCount() {
		return data.length;
	}

	@Override
	public int getColumnCount() {
		// todas las filas tienen las mismas columnas
		return cols.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return data[rowIndex][columnIndex];
	}
	
	// las celdas no son editables.
	public boolean isCellEditable(int row, int col) {
		return false;
	}
	
	public Class getColumnClass(int col) {
		return data[0][col].getClass();
	}
	
	private String [] cols;
	private Object [][] data;

}
